/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

/**
 *
 * @author Danilo
 */

// tipos de cartas:
//  10 = block
//  11 = +2
//  12 Neutral

public class Carta
{
    private String cor;
    private int valor;

    public Carta(String cor, int valor)
    {
        this.cor = cor;
        this.valor = valor;
    }

   
    
    public Carta(String cor, int valor, String tipo)
    {
        this.cor = cor;
        this.valor = valor;
    }
    
    public Carta()
    {}

    public String getCor()
    {
        return cor;
    }

    public void setCor(String cor)
    {
        this.cor = cor;
    }

    public int getValor()
    {
        return valor;
    }

    public void setValor(int valor)
    {
        this.valor = valor;
    }
    
//    public boolean isFOUR()
//    {
//        if(this.valor )
//            return true;
//        else
//            return false;
//    }
    
    public boolean isNEUTRAL()
    {
        if(this.valor == 12)
            return true;
        else
            return false;
    }
    
    public boolean isBLOCK()
    {
        if(this.valor == 10)
            return true;
        else
            return false;
    }
    
    public boolean isTWO()
    {
        if(this.valor == 11)
            return true;
        else
            return false;
    }
    
    public boolean isCompatible(Carta adv)
    {
        if(adv == null)
            return true;
        
        if(this.valor != 12)
        {
            if(this.valor == adv.getValor())
                return true;
        }
        else if(this.isNEUTRAL() && !(adv.valor >= 10 && adv.valor <= 11))
            return true;
        else
        {
            if(this.cor.equals(adv.getCor()) || this.valor == adv.getValor())
                return true;
        }
        
        return false;
    }
    
    public boolean isIdentico(Carta comp)
    {
        if(this.cor.equals(comp.getCor()) || this.valor == comp.getValor())
            return true;
        
        return false;
    }
    
    @Override
    public String toString()
    {
        String texto = "";
        
        if(isBLOCK())
        {
            texto += "BLOCK" + "|" + this.cor;
        }
        else if(isNEUTRAL())
        {
            texto += "NEUTRAL";
        }
        else if(isTWO())
        {
            texto += "TWO" + "|" + this.cor;
        } 
        
        return texto;
    }
}
